
package cn.com.pusai.core.util;

import java.util.HashMap;

// Referenced classes of package cn.com.ecinc.util:
//			VType

public class ClassTypeUtil
{

	public static final int INTEGER = 0;
	public static final int FLOAT = 1;
	public static final int DOUBLE = 2;
	public static final int BIGDECIMAL = 3;
	public static final int BOOLEAN = 4;
	public static final int STRING = 5;
	public static final int DATE_SQL = 6;
	public static final int TIMESTAMP = 7;
	public static final int SYBASETIME = 8;
	public static final int LONG = 9;
	public static final int DATE_UTIL = 10;
	public static final int BYTE = 11;
	public static final int SHOlRT = 12;
	private static final HashMap map;

	public ClassTypeUtil()
	{
	}

	public static int getTypeByClass(Class _cls)
	{
		return getTypeByClassName(_cls.getName());
	}

	public static int getTypeByClass(String _clsName)
	{
		return getTypeByClassName(_clsName);
	}

	public static int getTypeByClassName(String _clsName)
	{
		Integer riv = (Integer)map.get(_clsName);
		if (riv == null)
			return -1;
		else
			return riv.intValue();
	}

	public static boolean isNumberType(Class _cls)
	{
		return isNumberType(_cls.getName());
	}

	public static boolean isNumberType(String _clsName)
	{
		switch (getTypeByClass(_clsName))
		{
		case 0: // '\0'
			return true;

		case 1: // '\001'
			return true;

		case 2: // '\002'
			return true;

		case 3: // '\003'
			return true;

		case 9: // '\t'
			return true;

		case 11: // '\013'
			return true;

		case 12: // '\f'
			return true;

		case 4: // '\004'
		case 5: // '\005'
		case 6: // '\006'
		case 7: // '\007'
		case 8: // '\b'
		case 10: // '\n'
		default:
			return false;
		}
	}

	public static VType getVType(Object obj)
	{
		switch (getTypeByClass(obj.getClass()))
		{
		case 0: // '\0'
			return VType.Integer;

		case 1: // '\001'
			return VType.Float;

		case 2: // '\002'
			return VType.Double;

		case 3: // '\003'
			return VType.BigDecimal;

		case 4: // '\004'
			return VType.Boolean;
		

		case 5: // '\005'
			return VType.String;

		case 6: // '\006'
			return VType.Date_sql;
					
		case 7: // '\007'
			return VType.Timestamp;

		case 8: // '\b'
			return VType.Date_sybase;
			
		case 9: // '\t'
			return VType.Long;
			

		case 10: // '\n'
			return VType.Date_util;		

		case 11: // '\013'
			return VType.Byte;

		case 12: // '\f'
			return VType.Short;
		}
		return VType.Unvalid;
	}

	public static void main(String args1[])
	{
	}

	static 
	{
		map = new HashMap();
		map.put("java.lang.Integer", new Integer(0));
		map.put("java.lang.Float", new Integer(1));
		map.put("java.lang.Double", new Integer(2));
		map.put("java.math.BigDecimal", new Integer(3));
		map.put("java.lang.Boolean", new Integer(4));
		map.put("java.lang.String", new Integer(5));
		map.put("java.sql.Date", new Integer(6));
		map.put("java.sql.Timestamp", new Integer(7));
		map.put("com.sybase.jdbc2.tds.SybTimestamp", new Integer(8));
		map.put("java.lang.Long", new Integer(9));
		map.put("java.util.Date", new Integer(10));
		map.put("java.lang.Byte", new Integer(11));
		map.put("java.lang.Short", new Integer(12));
	}
}
